<form action="<?=PHP_SELF?>" method="post">
	<input type="hidden" name="clase[id_clase]" value="<?=empty($id_clase)?0:$id_clase?>"/>

	<table style="width:100%">
		<tr>
			<th colspan="3"><input class="openmodalbox"	type="submit" value="Guardar Datos" /></th>
		</tr>
		<tr>
			<td rowspan="6"><img src="<?=empty($img)?null:BASE_URL_FULL .'/'.ltrim($img,'/')?>" alt="" style="max-width:128px;max-height:128px" id="preview_foto"></td>
		</tr>
		<tr>
			<td>Id Name</td>
			<td><input type="text" name="clase[id_name]" value="<?=empty($id_name)?null:$id_name?>" placeholder="Ejm:salado" required="required"/></td>
		</tr>
		<tr>
			<td>Abreviacion</td>
			<td><input type="text" name="clase[abrev]" value="<?=empty($abrev)?null:$abrev?>" placeholder="Ejm: salados"/></td>
		</tr>
        <tr>
			<td>Nombre</td>
			<td><input type="text" name="clase[name]" value="<?=empty($name)?null:$name?>" placeholder="Ejm: Platos salados"/></td>
		</tr>
		<tr>
			<td>Imagen</td>
			<td><input type="text" name="clase[img]" value="<?=empty($img)?null:$img?>" id="image_input"/>
				<button onclick="buscar_imagen(this)" type="button">[ELEGIR]</button></td>
		</tr>
		<tr>
			<td colspan="2">
			<fieldset style="margin:0px; padding:2px;">
				<legend>Descripcion o texto</legend>
				<textarea name="clase[texto]" id="" cols="30" rows="5" style="width:100%"><?=empty($texto)? null:$texto?></textarea>
			</fieldset></td>
		</tr>
		<tr>
			<th colspan="3"><input class="openmodalbox"	type="submit" value="Guardar Datos" /></th>
		</tr>
	</table>
</form>
<script type="text/javascript">
function elegir_imagen(url)
{
	
	document.getElementById('preview_foto').src = '<?=BASE_URL_FULL .'/'?>' + url;
	document.getElementById('image_input').value=url;
	return true;
}
function buscar_imagen(button)
{
	index = document.getElementById('animal_folder').selectedIndex;
	var folder = document.getElementById('animal_folder').options[index].value;
	/*if(folder=='')
	{
		alert("Elija el nombre del ANIMAL y recien podra agregar Imagenes correspondientes");
		return 0;
	}*/
	$(button).attr("disabled","disabled");
	var resultado = window.open ( "<?=BASE_URL?>/admin/elegir_imagen.php?dir=/image/carne/|/image/carne/<?=@$_GET['folder']?>/"+folder, "ElegirImagen","status=0,toolbar=0");
	 /*$(resultado.document).ready(function() {
       
    })/**/
 	$(resultado).on('unload', function(){
		if(resultado.location != 'about:blank')
		{
			$(button).removeAttr("disabled");
		}
    });
}
</script>